package academic.ui.client.rules;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.IsSerializable;

public class Rules implements IsSerializable {
	
	public Rules() {}
	
	public static int REGISTER_ERROR_USER_EXISTS = -2;
	public static int LOGIN_ERROR_USER_NOT_FOUND = -1;
	public static int SUCCESS = 1;
	/**
	 * Returns true if the string is a valid email address
	 */
	public static Boolean validEmail(String email){
			return email.matches(".+@.+\\.[a-z]+");
	}
	
	public static String[] getFirstLastNames(String nameStr)
	{
		String[] names = nameStr.split("\\W");
		String firstName="";
		String lastName="";
		for(int i=0;i<names.length;i++)
		{
			if(i+1==names.length)
				lastName=names[i];
			else
				firstName+=names[i];
		}
		String[] nameResult= new String[2];
		nameResult[0]=firstName;
		nameResult[1]=lastName;
		
		return nameResult;
	}
	
}
